
import 'dart:async';
import '../utils/ApiService.dart';
import 'definitions/ResultRtcRoomModel.dart';
import 'definitions/CreatedRtcRoomParams.dart';
import 'definitions/ResultModel.dart';


class RtcRoomController {

    static String createdUsingPostPath = "/api/rtc/created";
    /// 1. 创建房间
    static Future<ResultRtcRoomModel> createdUsingPost(CreatedRtcRoomParams data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/rtc/created", data.toJson() , headers);
      return ResultRtcRoomModel()..fromJson(response.data);
    }
    
    static String joinRoomUsingPutPath = "/api/rtc/join/{room_id}";
    /// 2. 加入房间
    static Future<ResultModel> joinRoomUsingPut(String room_id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/rtc/join/$room_id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String exitRoomUsingPutPath = "/api/rtc/exit/{room_id}";
    /// 3. 退出房间
    static Future<ResultModel> exitRoomUsingPut(String room_id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/rtc/exit/$room_id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String heartbeatUsingPutPath = "/api/rtc/heartbeat/{room_id}";
    /// 4. 用户心跳
    static Future<ResultModel> heartbeatUsingPut(String room_id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/rtc/heartbeat/$room_id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String currentUsingGetPath = "/api/rtc/current";
    /// 5. 用户当前的房间
    static Future<ResultModel> currentUsingGet([dynamic headers]) async {
      var response = await ApiService.get("/api/rtc/current", {}, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String infoUsingGetPath = "/api/rtc/info/{room_id}";
    /// 6. 通话的房间
    static Future<ResultRtcRoomModel> infoUsingGet(String room_id, [dynamic headers]) async {
      var response = await ApiService.get("/api/rtc/info/$room_id", {}, headers);
      return ResultRtcRoomModel()..fromJson(response.data);
    }
    
    static String rejectUsingPutPath = "/api/rtc/reject/{room_id}";
    /// 7. 拒绝接听
    static Future<ResultModel> rejectUsingPut(String room_id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/rtc/reject/$room_id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String acceptUsingPutPath = "/api/rtc/accept/{room_id}";
    /// 8. 接听
    static Future<ResultModel> acceptUsingPut(String room_id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/rtc/accept/$room_id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String endUsingPutPath = "/api/rtc/end/{room_id}";
    /// 9. 主动挂断
    static Future<ResultModel> endUsingPut(String room_id, [ dynamic headers ]) async {
      var response = await ApiService.put("/api/rtc/end/$room_id", null, headers);
      return ResultModel()..fromJson(response.data);
    }
    
}